package com.itheima.spring.bestpractive.config;

import com.itheima.spring.bestpractive.common.interceptor.MyHandleInterceptor;
import com.itheima.spring.bestpractive.myinterceptor.AdminPermissionInterceptor;
import com.itheima.spring.bestpractive.myinterceptor.EvaluatorPermissionInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @version 1.0
 * @author: HZY
 * @date: 2025/6/24 23:23
 * @Content:
 */
@Configuration
public class MyTokenConfig implements WebMvcConfigurer {
    @Autowired
    private MyHandleInterceptor myHandleInterceptor;
    @Autowired
    private AdminPermissionInterceptor adminPermissionInterceptor;

    @Autowired
    private EvaluatorPermissionInterceptor evaluatorPermissionInterceptor;

    @Override
    public void addInterceptors(org.springframework.web.servlet.config.annotation.InterceptorRegistry registry) {
        registry
                .addInterceptor(myHandleInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/home/**","/login/**","/logout");
        registry.addInterceptor(adminPermissionInterceptor)
                .addPathPatterns("/admin/**");
        registry.addInterceptor(evaluatorPermissionInterceptor)
                .addPathPatterns("/evaluator/**");
    }
}
